import { Pipe, PipeTransform } from '@angular/core';

/**
 * 定制优惠券状态
 */
export const customizedCouponStatusArr = [
  {value: 1, label: '审核通过', color: '#008000'},
  {value: 2, label: '进行中', color: '#ff9900'},
  {value: 3, label: '已结束', color: '#bfbfbf'},
  {value: 4, label: '已停止', color: '#bfbfbf'},
  {value: 5, label: '草稿', color: '#bfbfbf'},
  {value: 6, label: '待审核', color: '#909399'},
  {value: 7, label: '审核不通过', color: '#ff4d4f'}
];
@Pipe({
  name: 'customizedCouponStatus'
})
export class CustomizedCouponStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = customizedCouponStatusArr.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj[type] || '-';
    } else {
      return tempObj[type] || '#909399';
    }
  }
}

/**
 * 定制用户优惠券状态
 */
export const userCouponStatusArr = [
  {value: 1, label: '待使用', color: '#008000'},
  // {value: 2, label: '售后中', color: '#909399'},
  {value: 3, label: '已过期', color: '#909399'},
  {value: 4, label: '已使用', color: '#909399'},
  {value: 5, label: '强制停止', color: '#909399'}
];
@Pipe({
  name: 'adzUserCouponStatus'
})
export class AdzUserCouponStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = userCouponStatusArr.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj[type] || '-';
    } else {
      return tempObj[type] || '#909399';
    }
  }
}

/**
 * 定制直降促销状态
 */
export const customizedDescentStatusArr = [
  {value: 1, label: '未开始', color: '#008000'},
  {value: 2, label: '进行中', color: '#FF9900'},
  {value: 3, label: '已结束', color: '#888888'},
  {value: 4, label: '已停止', color: '#888888'},
  {value: 5, label: '草稿', color: '#888888'},
  {value: 6, label: '待审核', color: '#888888'},
  {value: 7, label: '审核不通过', color: '#ff4d4f'}
];
@Pipe({
  name: 'customizedDescentStatus'
})
export class CustomizedDescentStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = customizedDescentStatusArr.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj?.label || '-';
    } else {
      return tempObj?.color || '#909399';
    }
  }
}

/**
 * 定制 订单状态
 */
export const customizedOrderStatusArr = [
  {value: 2, label: '待付款', color: '#409EFF'},
  {value: 3, label: '待发货', color: '#E6A23C'},
  {value: 4, label: '待发货', color: '#E6A23C'},
  {value: 5, label: '待发货', color: '#E6A23C'},
  {value: 6, label: '待发货', color: '#E6A23C'},
  {value: 7, label: '待发货', color: '#E6A23C'},
  {value: 8, label: '待收货', color: '#303133'},
  {value: 9, label: '交易完成', color: '#67C23A'},
  {value: 10, label: '支付超时', color: '#F56C6C'},
  {value: 11, label: '客服取消', color: '#67C23A'},
  {value: 12, label: '客户取消', color: '#F56C6C'},
  {value: 16, label: '交易结束', color: '#F56C6C'}
];
@Pipe({
  name: 'customizedOrderStatus'
})
export class CustomizedOrderStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = customizedOrderStatusArr.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj?.label || '-';
    } else {
      return tempObj?.color || '#909399';
    }
  }
}